package edu.kjxy.day02.suspend_resume_nosameValue;

/**
 * 功能:暂停线程的缺点--不同步
 * 程序运行的结果出现值不同步的情况，所以在程序中使用暂停线程suspend方法要格外注意
 * 作者:程序员欧阳子韩
 * 日期:2024/2/1 12:48
 */
public class RunTest {
    public static void main(String[] args) throws InterruptedException {
        final MyObject object = new MyObject();
        Thread thread = new Thread() {
            @Override
            public void run() {
                object.setValue("a", "aa");
            }
        };
        thread.setName("a");
        thread.start();
        Thread.sleep(500);
        Thread thread1 = new Thread() {
            @Override
            public void run() {
                object.printUsernamePassword();
            }
        };
        thread1.start();
    }
}
